﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;
using System.Text;
/// <summary>
/// javascript脚本类，本例子只有一个脚本提示函数
/// </summary>
public class Jscript
{
	public Jscript()
	{
		//
		// TODO: 在此处添加构造函数逻辑
		//
	}

    /// <summary>
    /// 弹出JavaScript小窗口
    /// </summary>
    /// <param name="js">窗口信息</param>
    static public void Alert(string message)
    {
        #region
        string js = @"<Script language='JavaScript'>
                    alert('" + message + "');</Script>";
        HttpContext.Current.Response.Write(js);
        #endregion
    }

    /// <summary>
    /// 显示一个弹出窗口，并转向当前页(刷新)
    /// </summary>
    /// <param name="str"></param>
   static public void ShowLocation(string str)
    {
        StringBuilder sb = new StringBuilder();
        sb.Append("<script language=\"javascript\"> \n");
        sb.Append("alert(\"" + str.Trim() + "\"); \n");
        sb.Append("window.location.href=window.location.href;\n");
        sb.Append("</script>");
        System.Web.HttpContext.Current.Response.Write(sb.ToString());
    }

    /// <summary>
    /// 显示一个弹出窗口，并转向目标页(导航)
    /// </summary>
    /// <param name="str"></param>
    /// <param name="url"></param>
   static public void ShowRedirect(string str, string url)
    {
        StringBuilder sb = new StringBuilder();
        sb.Append("<script language=\"javascript\"> \n");
        sb.Append("alert(\"" + str.Trim() + "\"); \n");
        sb.Append("window.location.href=\"" + url.Trim() + "\";\n");
        sb.Append("</script>");
        System.Web.HttpContext.Current.Response.Write(sb.ToString());
    }
}
